<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.springframework.org/schema/data/jaxb">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <script th:src="@{/managerstatic/plugins/jquery.min.js}"></script>
    <script th:inline="none">
        function uploadImg() {
            var formData = new FormData($('#uploadForm')[0]);
            $.ajax({
                type: 'post',
                url: "/imgUpload/insert",
                data: formData,
                cache: false,
                processData: false,
                contentType: false,
                success: function(data) {
                    if (data == null || data == "") {
                        alert("上传文件格式不合法!");
                    } else {
                        alert("上传成功！");
                    }
                },
            });
        }
    </script>
    <form class="card p-2" id="uploadForm" enctype="multipart/form-data">
        <div class="input-group">
            <input type="file" id="uploadFile" name="uploadFile">
        </div>
    </form>
    <br />
    <button type="button" class="btn btn-warning" style="width: 100px; margin: auto;" onclick="uploadImg()">上传头像</button>
</body>
</html>